package com.mlnx.push.websocket.server.handler;


import com.mlnx.common.utils.MyLog;
import com.mlnx.device.session.SessionManagerFactory;

import org.shan.mq.session.core.Session;
import org.shan.mq.session.core.SessionManager;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class EventHandle extends ChannelInboundHandlerAdapter {

	protected MyLog log = MyLog.getLog(getClass());

	protected SessionManager sessionManager = SessionManagerFactory.getInstance().getPushSessionManager();

	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
			throws Exception {
		log.error("exceptionCaught", cause);

		Session session = sessionManager.getSession(ctx.channel());
		if (session == null) {
			return;
		}
		sessionManager.removeSession(ctx.channel());

	}

}
